Skip to content

The Base DataModels

We provide different backend-dependent DataModels to use.

These data models provide I/O for chatbots, agents, rags etc.

The user can build new data models by inheriting from these base models.

The check functions works for every type of data models (by checking the schema) e.g. SymbolicDataModel, JsonDataModel, DataModel or Variable.

Embedding

Bases: DataModel

An embedding vector

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.Embedding",
    ]
)
class Embedding(DataModel):
    """An embedding vector"""

    embedding: List[float] = Field(
        description="The embedding vector",
        default=[],
    )

EmbeddingRequest

Bases: DataModel

Input for an embedding model: a single text or a batch.

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.EmbeddingRequest",
        "synalinks.EmbeddingRequest",
    ]
)
class EmbeddingRequest(DataModel):
    """Input for an embedding model: a single text or a batch."""

    texts: Union[str, List[str]] = Field(
        description="A text or list of texts to embed",
    )

Embeddings

Bases: DataModel

A list of embeddings

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.Embeddings",
        "synalinks.Embeddings",
    ]
)
class Embeddings(DataModel):
    """A list of embeddings"""

    embeddings: List[List[float]] = Field(
        description="The list of embedding vectors",
        default=[],
    )

GenericIO

Bases: DataModel

A pair of generic inputs/outputs

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.GenericIO",
        "synalinks.GenericIO",
    ]
)
class GenericIO(DataModel):
    """A pair of generic inputs/outputs"""

    inputs: Dict[str, Any] = Field(
        description="The inputs",
    )
    outputs: Dict[str, Any] = Field(
        description="The outputs",
    )

GenericInputs

Bases: DataModel

A generic inputs

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.GenericInputs",
        "synalinks.GenericInputs",
    ]
)
class GenericInputs(DataModel):
    """A generic inputs"""

    inputs: Dict[str, Any] = Field(
        description="The inputs",
    )

GenericOutputs

Bases: DataModel

A generic outputs

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.GenericOutputs",
        "synalinks.GenericOutputs",
    ]
)
class GenericOutputs(DataModel):
    """A generic outputs"""

    outputs: Dict[str, Any] = Field(
        description="The outputs",
    )

GenericResult

Bases: DataModel

A generic result

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.GenericResult",
        "synalinks.GenericResult",
    ]
)
class GenericResult(DataModel):
    """A generic result"""

    result: List[Any] = Field(
        description="The result",
    )

Instructions

Bases: Trainable

The instructions for the language model

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.Instructions",
        "synalinks.Instructions",
    ]
)
class Instructions(Trainable):
    """The instructions for the language model"""

    instructions: Optional[str] = Field(
        description="The instructions for the language model",
    )

is_embedded(x)

Checks if the given data model is an embedded entity

Parameters:

Name Type Description Default
x DataModel | JsonDataModel | SymbolicDataModel | Variable

The data model to check.

required

Returns:

Type Description
bool

True if the condition is met

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.is_embedded",
        "synalinks.is_embedded",
    ]
)
def is_embedded(x):
    """Checks if the given data model is an embedded entity

    Args:
        x (DataModel | JsonDataModel | SymbolicDataModel | Variable):
            The data model to check.

    Returns:
        (bool): True if the condition is met
    """
    schema = x.get_schema()
    properties = schema.get("properties", None)
    if properties:
        if properties.get("embedding", None):
            return True
    return False

is_embedding(x)

Checks if the given data model is an embedding

Parameters:

Name Type Description Default
x DataModel | JsonDataModel | SymbolicDataModel | Variable

The data model to check.

required

Returns:

Type Description
bool

True if the condition is met

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.is_embedding",
        "synalinks.is_embedding",
    ]
)
def is_embedding(x):
    """Checks if the given data model is an embedding

    Args:
        x (DataModel | JsonDataModel | SymbolicDataModel | Variable):
            The data model to check.

    Returns:
        (bool): True if the condition is met
    """
    if contains_schema(x.get_schema(), Embedding.get_schema()):
        return True
    return False

is_embeddings(x)

Checks if the given data model are embeddings

Parameters:

Name Type Description Default
x DataModel | JsonDataModel | SymbolicDataModel | Variable

The data model to check.

required

Returns:

Type Description
bool

True if the condition is met

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.is_embeddings",
        "synalinks.is_embeddings",
    ]
)
def is_embeddings(x):
    """Checks if the given data model are embeddings

    Args:
        x (DataModel | JsonDataModel | SymbolicDataModel | Variable):
            The data model to check.

    Returns:
        (bool): True if the condition is met
    """
    if contains_schema(x.get_schema(), Embeddings.get_schema()):
        return True
    return False

is_instructions(x)

Checks if the given data model is an instructions data model

Parameters:

Name Type Description Default
x DataModel | JsonDataModel | SymbolicDataModel | Variable

The data model to check.

required

Returns:

Type Description
bool

True if the condition is met

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.is_instructions",
        "synalinks.is_instructions",
    ]
)
def is_instructions(x):
    """Checks if the given data model is an instructions data model

    Args:
        x (DataModel | JsonDataModel | SymbolicDataModel | Variable):
            The data model to check.

    Returns:
        (bool): True if the condition is met
    """
    if contains_schema(x.get_schema(), Instructions.get_schema()):
        return True
    return False

is_prediction(x)

Checks if the given data model is a prediction

Parameters:

Name Type Description Default
x DataModel | JsonDataModel | SymbolicDataModel | Variable

The data model to check.

required

Returns:

Type Description
bool

True if the condition is met

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.is_prediction",
        "synalinks.is_prediction",
    ]
)
def is_prediction(x):
    """Checks if the given data model is a prediction

    Args:
        x (DataModel | JsonDataModel | SymbolicDataModel | Variable):
            The data model to check.

    Returns:
        (bool): True if the condition is met
    """
    if contains_schema(x.get_schema(), Prediction.get_schema()):
        return True
    return False

is_stamped(x)

Checks if the given data model is stamped

Parameters:

Name Type Description Default
x DataModel | JsonDataModel | SymbolicDataModel | Variable

The data model to check.

required

Returns:

Type Description
bool

True if the condition is met

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.is_stamped",
        "synalinks.is_stamped",
    ]
)
def is_stamped(x):
    """Checks if the given data model is stamped

    Args:
        x (DataModel | JsonDataModel | SymbolicDataModel | Variable):
            The data model to check.

    Returns:
        (bool): True if the condition is met
    """
    schema = x.get_schema()
    properties = schema.get("properties", None)
    if properties:
        if properties.get("created_at", None):
            return True
    return False

is_trainable(x)

Checks if the given data model is Trainable

Parameters:

Name Type Description Default
x DataModel | JsonDataModel | SymbolicDataModel | Variable

The data model to check.

required

Returns:

Type Description
bool

True if the condition is met

Source code in synalinks/src/backend/pydantic/base.py
@synalinks_export(
    [
        "synalinks.backend.is_trainable",
        "synalinks.is_trainable",
    ]
)
def is_trainable(x):
    """Checks if the given data model is Trainable

    Args:
        x (DataModel | JsonDataModel | SymbolicDataModel | Variable):
            The data model to check.

    Returns:
        (bool): True if the condition is met
    """
    if contains_schema(x.get_schema(), Trainable.get_schema()):
        return True
    return False